package com.gp8.tier3;

import java.io.Serializable;

//Pour RMI
import java.rmi.Remote;
import java.rmi.RemoteException;


//Pour REST
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import java.util.Date;

@XmlRootElement(name = "Piafferie")
public class Piafferie implements Serializable, Remote {

	private static final long serialVersionUID = 1L;
	private Piaffeur auteur;
	private String message;
	private Date date;
	
	
	public Piafferie(Piaffeur pAuteur, String pMessage) throws RemoteException {
		super();
		this.setAuteur(pAuteur);
		this.setMessage(pMessage);
		this.setDate(new Date());
	}

	
	public Piaffeur getAuteur() throws RemoteException {
		return auteur;
	}
	
	public void setAuteur(Piaffeur pAuteur) throws RemoteException {
		this.auteur = pAuteur;
	}
	
	public String getMessage() throws RemoteException {
		return message;
	}
	
	public void setMessage(String pMessage) throws RemoteException {
		this.message = pMessage;
	}
	
	public Date getDate() throws RemoteException {
		return date;
	}
	
	public void setDate(Date pDdate) throws RemoteException {
		this.date = pDdate;
	}
	
	@Override
    public boolean equals(Object object)
    {
        boolean same = false;

        if (object != null && object instanceof Piaffeur)
        {
        	same = (this.message.equals(((Piafferie)object).message) && this.auteur.equals(((Piafferie)object).auteur));
        }

        return same;
    }
	
	@Override
    public int hashCode() {
        int hash = 1;
        hash = hash + message.hashCode();
        hash = hash + auteur.hashCode();
        return hash;
    }
	
}
